/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.mortbay.jetty.pico.pages;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.mortbay.jetty.pico.dao.item.ItemDAO;
import org.mortbay.jetty.pico.entities.Item;

/**
 *
 * @author Dang
 */
public class ProductDetail {

    @Property
    private Item ownItem;
    private String idItem;
    @InjectPage
    private Index indexPage;
    @Inject
    private ItemDAO itemDAO;

    // onActivate() is called by Tapestry to pass in the activation context from the URL.
    public Object onActivate(String itemId) {
        if(itemId == null || itemId.equalsIgnoreCase("")){return indexPage;}

        this.idItem = itemId;

        ownItem = itemDAO.getItemByID(idItem);
        if (ownItem == null) {
            return indexPage;
        }
        return null;
    }
}
